<!-- 分管领导控件 -->

<template>
  <a-space direction="vertical" style="width: 100%">
    <div
      :style="{
        display: 'flex'
      }"
    >
      <a-tooltip position="rt">
        <icon-exclamation-circle-fill class="icon" />
        <template #content> {{ desc }} </template>
      </a-tooltip>
      <a-select
        :placeholder="getProps.placeholder"
        allow-search
        v-model="modelValue"
        :disabled="disabled"
      >
        <a-option
          v-for="item in list"
          :value="item.id"
          :label="item.name"
          :key="item.id"
        ></a-option>
      </a-select>
    </div>
  </a-space>
</template>

<script lang="ts" setup>
import { GetUserList } from '@/apis/management/user';
const props = withDefaults(
  defineProps<{
    props: { [propName: string]: any };
    name?: string;
    required?: boolean;
    oneValue: any;
    disabled?: boolean;
    regex?: {
      [name: string]: {
        role: any;
        name: any;
      };
    };
  }>(),
  {}
);
const emit = defineEmits(['update:oneValue']);
const modelValue = computed({
  get: () => {
    return Number(props.oneValue);
  },
  set: (val) => {
    emit('update:oneValue', val);
  }
});
//复制一份props
const getProps = computed(() => {
  return props.props;
});

let desc =
  '如果该部门的部门负责人直属汇报的领导不是上级部门的主管领导，请设置为分管领导';

let list = ref();
const getData = async () => {
  try {
    const { content } = await GetUserList({
      page: 1,
      size: -1
    });
    list.value = content;
  } catch (error: unknown) {
    console.log(error);
  }
};
getData();
</script>

<style scoped lang="less">
.icon {
  display: block;
  position: relative;
  transform: translateY(8px);
  margin-right: 5px;
  font-size: 20px;
  color: #165dff;
}
</style>
